using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class LogIn : System.Web.UI.UserControl
{
    processUser pLogin;

    
    protected void Page_Load(object sender, EventArgs e)
    {
        pLogin = new processUser(); 
        txtUserName.Focus();
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtUserName.Text = "";
        txtPassword.Text = "";
        txtUserName.Focus();
    }
    protected void btnLogIn_Click(object sender, EventArgs e)
    {
        string username = txtUserName.Text;
        string password = txtPassword.Text;
        if (pLogin.checkUsers(username, password) > 0)
        {
            if (Session["UserName"] == null || Session["UserName"].ToString().Equals(""))
            {
                Session["UserName"] = username;
                Session["Password"] = password;
                Session.Timeout = 30;
                Response.Redirect("index.aspx");
            }            
        }
        else
        {
            Alert.Show("User is not valid!");
            //Response.Write("<script>alert('');</script>");
        }
    }

}
